<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List"%>    
<%@ page import="minipost.post.model.Post"%>
<%@ page import="minipost.post.PostBean"%>

<%
	request.setCharacterEncoding("UTF-8");
	String id = request.getParameter("id");
	Post post = null;
	PostBean postBean = new PostBean();
	post = postBean.getPostById(id);
	
	if (post == null) {
%>
	<jsp:forward page="404.html"></jsp:forward>
<%
	} else {
		List<Post> list = postBean.getAllPosts();
%>    

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>栏目</title>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/public.js"></script>
</head>
<body>
    <div id="head">
    </div>
    <div class="clean"></div>
    <div id="nav">
        <div class="content">
            <div class="left">
                <ul>
                    <li class="active"><a href="index.jsp">首页</a></li>
                    <li><a href="category.jsp?type=home">国内</a></li>
                    <li><a href="category.jsp?type=abroad">国外</a></li>
                    <li><a href="category.jsp?type=society">社会</a></li>
                    <li><a href="category.jsp?type=tech">科技</a></li>
                </ul>
            </div>
            <div class="right" id="current_time"></div>
        </div>
    </div>
    <div class="clean"></div>
    <div class="list_row">
        <div id="list">
            <div class="list_head">
                <a class="list_head_item" href="index.jsp" title="">首页</a>
                <span class="list_head_item splash">&gt;</span>
                <a class="list_head_item" href="category.jsp?type=<%= post.getPostType()%>" title=""><%= post.getPostType()%></a>
                <span class="list_head_item splash">&gt;</span>
                <span><%= post.getPostTitle()%></span>
            </div>
            <div class="content_content">
                    <div class="content_title">
                        <h1><%= post.getPostTitle()%></h1>
                    </div>                
                    <div class="content_time">
                    	<%= post.getPostAuthor()%>&nbsp;&nbsp;&nbsp;<%= post.getPostDateAsString()%>
                    </div>
                    <div class="content_unity">
                        <%= post.getPostContent()%>
                    </div>
                    <div class="content_return">
                        <a href="category.jsp?type=<%= postBean.getTypeKey(post.getPostType())%>" title="">返回列表</a>
                    </div>
                </div>
        </div>

        <div id="slider">
            <div class="slider_head">
                <span>推荐文档</span>
            </div>
            <div class="slider_content">
                <ul>
                <%
                	int length = list.size();
                	for (int i = 0; i < length; ++i) {
                		Post currentPost = list.get(i);
                %>
                    <li><a href="single.jsp?id=<%= currentPost.getId()%>" title=""><%= i + 1%>.<%= currentPost.getPostTitle()%></a></li>
                <%
                	}
                %>
                </ul>
            </div>
        </div>
    </div>
    <div class="clean"></div>
    <div id="foot">
        Copyright&copy;&nbsp;合肥工业大学网站设计基础
    </div>
</body>
</html>

<%
	}
%>